# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=hunspell-en
pkgver=2020.12.07
pkgrel=0
pkgdesc="English hunspell dictionaries"
url="http://wordlist.aspell.net/dicts/"
arch="noarch"
license="LGPL-2.0-or-later scowl"
subpackages="$pkgname-doc"
options="!check" # data only package
source="https://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_US-$pkgver.zip
	https://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_CA-$pkgver.zip
	https://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_GB-large-$pkgver.zip
	"

unpack() {
	msg "Unpacking sources..."
	mkdir -p "$builddir"
	cd "$builddir"
	for u in $source; do
		local s="$SRCDEST/$(filename_from_uri $u)"
		unzip $s
	done
}

prepare() {
	default_prepare
	sed -i "s:SET UTF8:SET UTF-8:g"  *.aff
}

package() {
	install -dm755 "$pkgdir"/usr/share/hunspell
	install -m644 en_*.dic en_*.aff "$pkgdir"/usr/share/hunspell

	local lang
	for lang in en_AG en_AU en_BS en_BW en_BZ en_DK en_GB en_GH en_HK en_IE en_IN en_JM en_NA en_NG en_NZ en_SG en_TT en_ZA en_ZW; do
		ln -svf en_GB-large.aff "$pkgdir"/usr/share/hunspell/$lang.aff
		ln -svf en_GB-large.dic "$pkgdir"/usr/share/hunspell/$lang.dic
	done
	for lang in en_PH; do
		ln -svf en_US.aff "$pkgdir"/usr/share/hunspell/$lang.aff
		ln -svf en_US.dic "$pkgdir"/usr/share/hunspell/$lang.dic
	done

	# docs
	install -dm755 "$pkgdir"/usr/share/doc/$pkgname
	install -m644 README_en_*.txt "$pkgdir"/usr/share/doc/$pkgname

	# licenses
	install -D -m644 README_en_US.txt "$pkgdir"/usr/share/licenses/$pkgname/Copyright_en_US
	install -D -m644 README_en_CA.txt "$pkgdir"/usr/share/licenses/$pkgname/Copyright_en_CA
	install -D -m644 README_en_GB-large.txt "$pkgdir"/usr/share/licenses/$pkgname/Copyright_en_GB-large
}

sha512sums="a35ff630883e2410164e21669e6a46d15c73c76d969829cbf20903949dc7815886c0907f192aad9d363f777dcc9acfbd1e60c8175fbebf14d551e1d6e524c075  hunspell-en_US-2020.12.07.zip
6e34bddbc1f8fd37c4b57d4520cd89a1f301430e7202cc35b0918ca856ff3eaba00743ef904a8b89f806812729976169826857a0fa2f452dd0ed922eeb6a9303  hunspell-en_CA-2020.12.07.zip
a402c40717cd185ea8c14be2d4dc7df67580f197d276ae660a7cf478ae3e07e469c78271feb0c4c6b7c1c418bfb10e7f42c1e5f4b9635a4d3c47e1af4a747a4c  hunspell-en_GB-large-2020.12.07.zip"
